/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package framework;

import framework.gameAPI.Sprite;
import game.Global;
import java.awt.Color;
import java.awt.Graphics;

/**
 *
 * @author aluno
 */
public class Tile extends GameObject {

    private boolean colision;
    private Sprite sprite;
    private boolean showColisionRect;

    //public Tile() {
    //    colision = false;
    //}
    public Tile(int x, int y, int[] frame) {
        this.sprite = new Sprite(Util.loadImage(Global.IMG_TILE), 32, 32);
        this.x = x;
        this.y = y;
        this.sprite.setFrameSequence(frame);
        this.width = sprite.getWidth();
        this.height = sprite.getHeight();
        this.sprite.defineCollisionRectangle(0, 0, width, height);

    }

    @Override
    public void update() {
    }

    @Override
    public void paint(Graphics g) {
        sprite.setX(x);
        sprite.setY(y);
        sprite.paint(g);

        if (isColision()) {
            if (sprite.showColisionRect) {
                g.setColor(Color.RED);
                g.drawRect(x, y + (sprite.getRect().y), sprite.getRect().width, sprite.getRect().height);

            }
        }
    }

    public boolean isColision() {
        return colision;
    }

    public void setColision(boolean colision) {
        this.colision = colision;
    }

    public Sprite getSprite() {
        return sprite;
    }

    public void setSprite(Sprite sprite) {
        this.sprite = sprite;
    }
}
